#include"process.h"
#include<stdio.h>
#include<string.h>
#include<unistd.h>

#define MAX 101
#define style '#'
/*void process()
{
  const char* arr="|/-\\";
  printf("begin\n");
  char bar[MAX];
  size_t len=strlen(arr);
  memset(bar,'\0',sizeof(bar));
  int cnt =0;
  while(cnt<MAX)
  {
    printf("[%-100s][%%%d][%c]\r",bar,cnt,arr[cnt%len]);
    fflush(stdout);
    bar[cnt]=style;
    cnt++;
    usleep(50000);
  }


}*/
#define icon '&'
void process(double current,double total)
{
  static int  num=0;
  char ss[6];
  int j=0;
  memset(ss,'\0',sizeof(ss));
  
  for(j=0;j<num%6;j++)
  {
      ss[j]=icon;
  }
  num++;
  char arr[MAX];
  memset(arr,'\0',sizeof(arr));
   double pro= (current/total)*100;
   int i=0;
   for( i=0;i<(int)pro;i++)
   {
       arr[i]=style;
   }
   printf("[%-100s][%d%%]%-6s\r",arr,(int)pro,ss);
  // printf("%-6s%d\r",ss,num);
   fflush(stdout);
   

}
